package com.bmw.regist.service.impl;


import cn.hutool.core.lang.Assert;
import com.bmw.regist.dao.UserDao;
import com.bmw.regist.model.Register;
import com.bmw.regist.model.User;
import com.bmw.regist.service.Registuser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;


@Service("Registuser")
@Slf4j
public class RegistUserImpl implements Registuser {
    @Autowired
    private UserDao userDao;
    @Override
    public User findByPhone(String phone) {
            Assert.notNull(phone);
            User user = new User();
            user.setPhone(phone);
            List<User> list = userDao.list(user);
            if (!CollectionUtils.isEmpty(list)) {
                Assert.isTrue(list.size() == 1);
                return list.get(0);
            }

            return null;
        }
}
